<?php
/**
 * Created by JetBrains PhpStorm.
 * User: shaoshuai
 * Date: 3/6/12
 * Time: 4:15 下午
 * To change this template use File | Settings | File Templates.
 */
date_default_timezone_set('PRC');
$sn = trim($_POST['sn']);
$content = file_get_contents('https://selfsolve.apple.com/warrantyChecker.do?sn=' . $sn . '&cb=done');
$content = substr($content, 5, -1);
$content = json_decode($content, true);
if (isset($content['ERROR_CODE'])) {
    exit($content['ERROR_DESC']);
}
//首次激活日期计算 待验证
$d = 0;
if (isset($content['DAYS_REM_IN_COV']) && !empty($content['COV_END_DATE'])) {
    $d = strtotime($content['COV_END_DATE']);
    $d = strtotime('-364 day', $d);
    //echo date('Y-m-d', $d - 3600 * 24 * 365);
}
file_put_contents($sn . '.txt', print_r($content, true));
//var_dump($content);
?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>iPhone序列号查询,iPhone激活时间查询,iPhone所有信息查询</title>
    <style>
        body {
            font-size: 14px;
        }
        .grid > div {
            line-height: 24px;
        }
        .label {
            display: inline-block;
            width: 120px;
        }
    </style>
</head>
<body>
<div class="grid">
    <div><span class="label">序列号</span><span class="value"><?php echo $content['SERIAL_ID'] ?></span></div>
    <div><span class="label">型号</span><span class="value"><?php echo $content['PROD_DESCR'] ?></span></div>
    <div><span class="label">机型</span><span class="value"><?php echo $content['PART_DESCR'] ?></span></div>
    <div><span class="label">购买日期</span><span class="value"><?php echo $content['PURCHASE_DATE'] ?></span></div>
    <div><span class="label">保修到期</span><span class="value"><?php echo $content['COV_END_DATE'] ?></span></div>
    <div><span class="label">首次激活日期</span><span class="value"><?php if ($d) { echo date('Y-m-d', $d); } ?></span></div>
    <div><span class="label">最后激活日期</span><span class="value"><?php echo $content['LAST_UNBRICK_DT'] ?></span></div>
    <div><span class="label">购买地点</span><span class="value"><?php echo $content['PURCH_COUNTRY'] ?></span></div>
    <div><span class="label">系统版本</span><span class="value"><?php echo $content['PROD_VERSION'] ?></span></div>
    <div><span class="label">电话支持</span><span class="value"><?php echo $content['PH_END_DATE'] ?></span></div>
    <div><span class="label">IMEI</span><span class="value"><?php echo $content['AP_IMEI_NUM'] ?></span></div>
</div>
<div><a href="index.html">返回继续查询</a> </div>
</body>
</html>

